package utils;

import java.io.File;

public class DeleteDirectory {
    public boolean delete(File destination) {
        if (destination == null || !destination.exists()) return false;
        boolean jdg = destination.delete();
        if (!jdg) {
            File[] files = destination.listFiles();
            if (files == null) return false;
            for (File file : files) {
                if (file.isFile()) {
                    file.delete();
                } else {
                    delete(file);
                }
            }
            jdg = destination.delete();
        }
        return jdg;
    }
}
